<template>
  <div class="factory-number">
    <div class="shade"></div>
    <div class="popup">
      <div class="title justify-content-between">
        <span class="fs28 colorFFF">出厂编号</span>
        <img src="../assets/images/icon-close.png" @click="cancel" />
      </div>
      <div class="content">
        <div class="c-title align-item-center">检查项目：{{taskName}}</div>
        <div class="theader justify-content-between">
          <div class="w1000">序号</div>
          <div class="w4000">名称</div>
          <div class="w4000">出厂编号</div>
        </div>
        <div class="tbodys">
          <div
            class="tbody justify-content-between"
            v-for="(item, index) in list"
            :key="index"
          >
            <div class="w1000">{{ index + 1 }}</div>
            <div class="w4000">{{item.matchName}}</div>
            <div class="w4000">
              <el-input
                v-model="item.matchNo"
                placeholder="请输入出厂编号"
              ></el-input>
            </div>
          </div>
        </div>
      </div>
      <div class="btns justify-content-center">
        <div class="btn sure" @click="save">确认</div>
        <div class="btn cancel" @click="cancel">取消</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "FactoryNumber",
  props: {
    id: Number,
    taskName: String
  },
  data() {
    return {
      list: [],
    };
  },
  created() {
    this.getDataList()
  },
  methods: {
    getDataList() {
      let _this = this;
      _this.axios.getFactoryNumber({
        taskId: this.id
      }).then(res => {
        console.log(res)
        if (res.code == 200) {
          _this.list = res.data.list
        }
      }).catch(function (error) {
        _this.$message.error(error.msg);
      });
    },
    save() {
      let _this = this;
      _this.axios.saveFactoryNumber({
        list: _this.list
      }).then(res => {
        if (res.code == 200) {
          _this.cancel(1)
        } else {
          _this.$message.error(res.msg)
        }
      }).catch(function (error) {
        _this.$message.error(error.msg);
      });
    },
    cancel(refresh) {
      this.$emit("cancel", refresh);
    },
  },
};
</script>

<style scoped lang='less'>
.factory-number {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  .shade {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
  }
  .popup {
    width: 6.66rem;
    height: 5.32rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    box-shadow: 0 0.05rem 0.15rem 0 rgba(0, 21, 54, 0.25);
    .title {
      width: 100%;
      height: 0.58rem;
      background-color: #285fe3;
      padding: 0 0.36rem 0 0.42rem;
      img {
        width: 0.23rem;
        height: 0.23rem;
        cursor: pointer;
      }
    }
    .content {
      width: 100%;
      padding: 0 0.45rem 0 0.4rem;
      .c-title {
        width: 100%;
        height: 0.69rem;
        line-height: 0.69rem;
        font-size: 0.24rem;
        color: #161d2e;
      }
      .theader {
        width: 100%;
        height: 0.4rem;
        background: #f4f5f8;
        border: 1px solid #d0d6e3;
        border-radius: 0.03rem;
        padding: 0 0.15rem;
      }
      .theader > div {
        text-align: center;
        font-size: 0.18rem;
        color: #505971;
      }
      .tbodys {
        width: 100%;
        height: 2.64rem;
        overflow-y: scroll;
      }
      /*.tbodys::-webkit-scrollbar {
        display: none;
      }
      .tbodys {
        scrollbar-width: none;
        -ms-overflow-style: none;
        overflow-x: hidden;
        overflow-y: auto;
      }*/
      .tbody {
        width: 100%;
        min-height: 0.6rem;
        border: 1px solid #d0d6e3;
        border-radius: 0.03rem;
        font-size: 0.18rem;
        color: #161d2e;
        margin-top: 0.03rem;
        padding: 0.09rem 0.15rem;
      }
      .w1000 {
        width: 10%;
        text-align: center;
      }
      .w4000 {
        width: 40%;
      }
    }
    .btns {
      width: 100%;
      position: absolute;
      bottom: 0.34rem;
      .btn {
        width: 1.3rem;
        height: 0.4rem;
        margin-left: 0.78rem;
        line-height: 0.4rem;
        text-align: center;
        border-radius: 0.03rem;
        font-size: 0.22rem;
        cursor: pointer;
      }
      .btn.sure {
        background: linear-gradient(0deg, #00a366 0%, #00c37a 100%);
        color: #fff;
      }
      .btn.cancel {
        border: 1px solid #316eff;
        background: linear-gradient(0deg, #d9dde8 0%, #ffffff 100%);
        color: #505971;
      }
      .btn:first-child {
        margin-left: 0;
      }
    }
  }
}

/deep/ .el-input__inner {
  height: 0.42rem;
  line-height: 0.42rem;
}
</style>